package test21;

/**
 * Created by tianxiadiyishuai on 2017/11/1.
 */
public class Test {
    //统计一个字符串中给定字符出现的频率
    public static void main(String[] args) {
        char c = '1';
        String string = "123456789111";
        System.out.println(getCharCount(c, string));
    }
    public static int getCharCount(char c, String string){
        int count = 0;
        for (int i = 0; i < string.length(); i++) {
            char temp = string.charAt(i);
            if(c == temp)
                count ++;
        }
        return count;
    }
}
